package org.gpp.proj1.bone;


import junit.framework.TestCase;

public class AnimationTest extends TestCase {

	/*
	 * Test method for 'org.gpp.proj1.bone.Animation.Animation(String, KeyframeInterval, boolean, int)'
	 */
	public void testAnimationStringKeyframeIntervalBooleanInt() {
		// Cannot create animation with null name
		try {
			new Animation( null, null, false, 0 );
			fail();
		} catch( AssertionError e ) {
			// expected error
		}
		
		// Cannot create animation with null interval
		try {
			new Animation( "Animation", null, false, 0 );
			fail();
		} catch( AssertionError e ) {
			// expected error
		}
		
		// Creating valid animation
		try {
			new Animation( "Animation", new KeyframeInterval( 0, 0 ), false, 0 );
		} catch( AssertionError e ) {
			fail();
		}
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.Animation.Animation(String, KeyframeInterval)'
	 */
	public void testAnimationStringKeyframeInterval() {
		// Cannot create animation with null name
		try {
			new Animation( null, null );
			fail();
		} catch( AssertionError e ) {
			// expected error
		}
		
		// Cannot create animation with null interval
		try {
			new Animation( "Animation", null );
			fail();
		} catch( AssertionError e ) {
			// expected error
		}
		
		// Creating valid animation
		try {
			new Animation( "Animation", new KeyframeInterval( 0, 0 ) );
		} catch( AssertionError e ) {
			fail();
		}
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.Animation.loops()'
	 */
	public void testLoops() {
		Animation anim = new Animation( "Animation", new KeyframeInterval( 0, 0 ) );
		
		assertFalse( anim.loops() );
		
		anim = new Animation( "Animation", new KeyframeInterval( 0, 0 ), false, 0 );
		
		assertFalse( anim.loops() );
		
		anim = new Animation( "Animation", new KeyframeInterval( 0, 0 ), true, 0 );
		
		assertTrue( anim.loops() );
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.Animation.getLoopFrame()'
	 */
	public void testGetLoopFrame() {
		Animation anim = new Animation( "Animation", new KeyframeInterval( 0, 0 ) );
		
		assertEquals( 0, anim.getLoopFrame() );
		
		anim = new Animation( "Animation", new KeyframeInterval( 2, 4 ) );
		
		assertEquals( 2, anim.getLoopFrame() );
		
		anim = new Animation( "Animation", new KeyframeInterval( 0, 0 ), false, 4 );
		
		assertEquals( 0, anim.getLoopFrame() );
		
		anim = new Animation( "Animation", new KeyframeInterval( 2, 4 ), true, 4 );
		
		assertEquals( 4, anim.getLoopFrame() );
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.Animation.getName()'
	 */
	public void testGetName() {
		Animation anim = new Animation( "Animation", new KeyframeInterval( 0, 0 ) );
		
		assertEquals( "Animation", anim.getName() );
	}

	/*
	 * Test method for 'org.gpp.proj1.bone.Animation.getInterval()'
	 */
	public void testGetInterval() {
		Animation anim = new Animation( "Animation", new KeyframeInterval( 0, 0 ) );
		
		assertEquals( new KeyframeInterval( 0, 0 ), anim.getInterval() );
	}

}
